package com.panda.business.controller.user;

import com.panda.business.domain.CommontermInfo;
import com.panda.business.service.CommontermService;
import com.panda.common.annotation.Log;
import com.panda.common.core.controller.BaseController;
import com.panda.common.core.domain.AjaxResult;
import com.panda.common.core.page.TableDataInfo;
import com.panda.common.enums.BusinessType;
import com.panda.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 部门公共术语Controller
 * 
 * @author panda
 * @date 2021-01-06
 */
@RestController
@RequestMapping("/business/commonterminfo")
public class TblCommonterminfoController extends BaseController
{
    @Autowired
    private CommontermService tblCommonterminfoService;

    /**
     * 查询部门公共术语列表
     */
    @PreAuthorize("@ss.hasPermi('business:commonterminfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CommontermInfo tblCommonterminfo)
    {
        startPage();
        List<CommontermInfo> list = tblCommonterminfoService.selectTblCommonterminfoList(tblCommonterminfo);
        return getDataTable(list);
    }

    /**
     * 导出部门公共术语列表
     */
    @PreAuthorize("@ss.hasPermi('business:commonterminfo:export')")
    @Log(title = "部门公共术语", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CommontermInfo tblCommonterminfo)
    {
        List<CommontermInfo> list = tblCommonterminfoService.selectTblCommonterminfoList(tblCommonterminfo);
        ExcelUtil<CommontermInfo> util = new ExcelUtil<CommontermInfo>(CommontermInfo.class);
        return util.exportExcel(list, "commonterminfo");
    }

    /**
     * 获取部门公共术语详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:commonterminfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tblCommonterminfoService.selectTblCommonterminfoById(id));
    }

    /**
     * 新增部门公共术语
     */
    @PreAuthorize("@ss.hasPermi('business:commonterminfo:add')")
    @Log(title = "部门公共术语", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CommontermInfo tblCommonterminfo)
    {
        return toAjax(tblCommonterminfoService.insertTblCommonterminfo(tblCommonterminfo));
    }

    /**
     * 修改部门公共术语
     */
    @PreAuthorize("@ss.hasPermi('business:commonterminfo:edit')")
    @Log(title = "部门公共术语", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CommontermInfo tblCommonterminfo)
    {
        return toAjax(tblCommonterminfoService.updateTblCommonterminfo(tblCommonterminfo));
    }

    /**
     * 删除部门公共术语
     */
    @PreAuthorize("@ss.hasPermi('business:commonterminfo:remove')")
    @Log(title = "部门公共术语", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tblCommonterminfoService.deleteTblCommonterminfoByIds(ids));
    }
}
